package cn.com.adapter;

import java.util.List;

import cn.com.R;
import cn.com.domain.Lifebk;
import cn.com.service.LifebkService;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 生活百科适配器
 * @author ChonZY
 */
public class LifebkAdapter extends BaseAdapter {
	private Context context ;
	private List<Lifebk> entitys ; 
	private LifebkService service ;
	private LayoutInflater mInflater  ;
	
	public LifebkAdapter(){
		super();
	}
	public LifebkAdapter(Context context, List<Lifebk> entitys){
		this.context = context;
		this.entitys = entitys ;
		mInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		service = new LifebkService();
	}

	@Override
	public int getCount() {
		return entitys.size();
	}

	@Override
	public Object getItem(int position) {
		return entitys.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = mInflater.inflate(R.layout.lv_lifebk_item, null);
		TextView tv_name = (TextView) view.findViewById(R.id.tv_lifebk_item_name);
		TextView tv_count = (TextView) view.findViewById(R.id.tv_lifebk_item_count);
		Lifebk entity = entitys.get(position);
		tv_name.setText(entity.getName());
		tv_count.setText("("+entity.getCount()+")");
		return view;
	}

}
